package bhbt.controller.member.wealth;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import bhbt.controller.core.BaseController;
import bhbt.model.Member;
import bhbt.model.WageCurrent;
import bhbt.service.WageCurrentService;
import bhbt.service.WageHistoryService;
import bhbt.taglib.pagetag.Pagination;
import bhbt.utils.ContextUtil;
import bhbt.utils.MapUtil;






/**
 * Created by Administrator on 2016/3/25.
 */
@Controller

public class WageListController extends BaseController {
    @Resource
    private WageHistoryService wageHistoryService;
    @Resource
    private WageCurrentService wageCurrentService;
   
   
    @RequestMapping("member/wealth/wageList.shtml")
    public String list(HttpServletRequest request) throws Exception{
        HashMap formMap = getParameterMap(request);
        String startDate = MapUtil.getString(formMap, "startDate");
        String endDate = MapUtil.getString(formMap, "endDate");
           
        if(startDate!=null&&!startDate.equals("")&&endDate!=null&&!endDate.equals("")){
        	//+1天
        	 
        	SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");//小写的mm表示的是分钟  
        	 
        	Date newEndDate=sdf.parse(endDate);  
        	
        	long temp=newEndDate.getTime()+24*60*60*1000;
			newEndDate=new Date(temp);
			
			String newEndDateString=sdf.format(newEndDate);  
        	formMap.put("where", " a.commitDate>= '"+startDate+"' and a.commitDate<= '"+newEndDateString+"'");	//  时间查询
        }
        Member member = ContextUtil.getMember();
        formMap.put("memberLoginName", member.getLoginName());	
        formMap.put("pagination.orderBy"," a.id desc");  //排列
        Pagination page = wageHistoryService.queryForPageList("wageHistoryForPage",formMap);
        request.setAttribute(Pagination.pageBeanName, page);
        
        
        
        Integer wageCurrentId = member.getWageCurrentId();
        WageCurrent wage = wageCurrentService.getByKey(wageCurrentId);
        
        request.setAttribute("wage", wage);
        
        return "member/wealth/wageList";
    }

    
}
